<template>
	<view>
		<u-toast ref="uToast" />
		<view class="myfunction">

			<view class="fun_item" @click="mycollect">
				<image src="/static/icons/collection.png" mode=""></image>
				<text>我的收藏</text>
			</view>
			<view class="fun_item" @click="getrecord">
				<image src="/static/icons/history.png" mode=""></image>
				<text>浏览记录</text>
			</view>
			<view class="fun_item" @click="mylike">
				<image src="/static/icons/praise.png" mode=""></image>
				<text>点赞</text>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		name: "myfunction",
		data() {
			return {
				token: '',
			};
		},
		props:["userInfo"],
		methods: {
			async mycollect() {
				if(this.userInfo) {
					console.log(this.userInfo);
					const result = await this.$api.profile.getcollect(this.token, {
						_id: this.userInfo._id
					});
					if (result.meta.status == 200) {
						// 暂无要求
						this.$refs.uToast.show({
							title: '暂无要求',
							type: 'error',
						})
					} else {
						this.$refs.uToast.show({
							title: result.meta.msg,
							type: 'error',
						})
					}
				}else{
					this.$refs.uToast.show({
						title: '请先登录',
						type: 'error',
					})
				}
				
			},
			async getrecord() {
				if(this.userInfo) {
					const result = await this.$api.profile.getrecord(this.token, {
						_id: this.userInfo._id
					});
					if (result.meta.status == 200) {
						// 暂无要求
						this.$refs.uToast.show({
							title: '暂无要求',
							type: 'error',
							url: ''
						})
					} else {
						this.$refs.uToast.show({
							title: result.meta.msg,
							type: 'error',
							url: ''
						})
					}
				}else{
					this.$refs.uToast.show({
						title: '请先登录',
						type: 'error',
					})
				}
				
			},
			async mylike() {
				// 暂无接口
				this.$refs.uToast.show({
					title: '暂无接口',
					type: 'error',
					url: ''
				})
			}
		},
		created() {
			uni.getStorage({
				key: 'token',
				success: ({
					data
				}) => {
					this.token = data;
				}
			})
		},
	}
</script>

<style scoped lang="scss">
	.myfunction {
		display: flex;
		justify-content: space-around;
		background: #FFFFFF;
		margin: 10rpx 0;
		padding: 10rpx;

		.fun_item {
			display: flex;
			flex-direction: column;
			align-items: center;

			>image {
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
</style>
